package com.scut.wordskillerbackend.controller;

import com.scut.wordskillerbackend.dto.RespBean;
import com.scut.wordskillerbackend.po.User;
import com.scut.wordskillerbackend.service.UserArchiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RestController
@RequestMapping("/archive")
public class UserArchiveController {
    @Autowired
    private UserArchiveService userArchiveService;

    @PutMapping("/update")
    public RespBean updateUser(@RequestParam String content,
                               @RequestHeader("Authorization") String authorization) {
        boolean result;
        try {
            result = userArchiveService.updateArchiveService(content, authorization);
        } catch (Exception e) {
            return RespBean.unprocessable("更新失败" + e.getMessage());
        }
        if (result) {
            return RespBean.ok("更新成功");
        }
        return RespBean.unprocessable("更新失败");
    }
}
